$(function () {

    var $btn = $("button")

    $btn.click(function (e) {
        e.preventDefault();

        var $name = $("#name");
        var $password = $("#password")
        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:8888/users/login",
            data: {
                username: $name.val(),
                password: $password.val()
            },
            dataType: "json",
            success: function (data) {
                console.log(data.code);
                if (data.code === 1) {
                    window.location.href = "../../dist/index.html"
                } else {
                    alert("账号或密码错误")
                }
            }
        });
    });
})